#include "TcpServer.hpp"
#include "Protocol.hpp"
#include "ServerCal.hpp"
#include <iostream>
#include <memory>
#include <string>
void Usage(const std::string& proc)
{
    std::cout << "\n\r" << proc << "prot[1024+]\n" << std::endl;
}
int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(1);
    }
    uint16_t port = std::stoi(argv[1]);
    ServerCal cal;
    TcpServer *tsvp = new TcpServer(port, std::bind(&ServerCal::Calculator, &cal, std::placeholders::_1));
    tsvp->InitServer();
    tsvp->Start();
    delete tsvp;

    //测试Request
    // Request req(1011111, 2022222, '+');
    // std::string s;
    // req.Serialize(&s);
    // s = Encode(s);
    // std::cout << s << std::endl;

    // std::string content;
    // Decode(s, &content);
    // req.Deserialize(content);

    // std::cout << req.x << req.oper << req.y << std::endl;

    //测试Response
    // Response res(111111, 222222);
    // std::string s;
    // res.Serialize(&s);
    // s = Encode(s);
    // std::cout << s << std::endl;

    // std::string content;
    // Decode(s, &content);
    // res.Deserialize(content);

    // std::cout << res.result << " " << res.exitcode << std::endl;

    return 0;
}